ATSUCustomAllocFunc

Defines a pointer to a memory allocation callback function. Your callback function manages memory allocation operations typically handled by ATSUI, including which heap to use and how memory allocation should occur.

typedef void * (*ATSUCustomAllocFunc)(void *refCon, ByteCount howMuch); You would declare your function like this if you were to name it MyATSUCustomAllocFunc:

void * MyATSUCustomAllocFunc (
                     void *refCon,
                     ByteCount howMuch);
refCon
A pointer to arbitrary data for use in your memory allocation callback function. ATSUI passes a pointer to data that your application previously supplied in the memoryRefCon field of the ATSUMemoryCallbacks union.

howMuch
The amount of memory (in bytes) that you need to allocate.

function result
An untyped pointer to the beginning of the block of memory allocated by your callback function.
DISCUSSION
You can register your callback function by calling the function ATSUCreateMemorySetting and passing the constant kATSUUseCallbacks in iHeapSpec and a pointer to the ATSUMemoryCallbacks union in iMemoryCallbacks. You then supply a pointer of type ATSUCustomAllocFunc in the Alloc field of the callbacks structure of the ATSUMemoryCallbacks union.

Note that your MyATSUCustomAllocFunc function is expected to return a pointer to the start of the allocated memory, unless it terminates in an application.

VERSION NOTES
Available beginning with ATSUI 1.1.


© 2000 Apple Computer, Inc. – (Last Updated 25 Jan 00)